import {baseUrl} from './env'
import axios from 'axios' //引入axios
/** 
 * url:链接  
 * method:方法    
 * data:参数    
 * baseUrl:大数据的后台url 
 * isShowMask:是否展示转圈圈，图片上传默认展示 */
export const fetch = (method, url, data, isShowMask = false) => {
    return new Promise((resolve, reject) => {
        // console.log(method, data, '......data')
        const header = {
            // 'Access-Control-Allow-Origin': '*',
            // 'content-type': 'application/json',
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Headers": "x-requested-with,content-type",
            "Content-Type": "application/x-www-form-urlencoded"
        }
        axios.request({
          data,
          method,
          header,
          url: baseUrl + url
        }).then(response => {
            resolve(response.data.data)
            // console.log(response, ' ...Res')
        }).catch(response => {
            reject(response.data)
        })
    })
}
